package com.lishilin.gulimall.search.controller;

import com.lishilin.gulimall.search.service.MallSearchService;
import com.lishilin.gulimall.search.vo.SearchParam;
import com.lishilin.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;


    @GetMapping("/list.html")
    public Object listPage(SearchParam param, Model model) {
        /*
         * spring mvc将页面提交过来的所有请求查询参数自动封装成指定的对象
         * */
        SearchResult result = mallSearchService.search(param);
//        使用model将检索到的值返回给页面
        model.addAttribute("result",result);

        return "list";
    }
}
